export default {
	data() {
		return {
			showScreen: false,
		
			settlement_list: [{
					type: 0,
					name: '全部'
				},
				{
					type: 1,
					name: '已结算'
				},
				{
					type: 2,
					name: '未结算'
				}
			],
			
			reply_list: [{
					type: 0,
					name: '全部'
				},
				{
					type: 1,
					name: '已回复'
				},
				{
					type: 2,
					name: '未回复'
				}
			],
			
			explain_list: [
				{
					type: '',
					name: '全部'
				},
				{
					type: 1,
					name: '好评'
				},
				{
					type: 2,
					name: '中评'
				},
				{
					type: 3,
					name: '差评'
				}
			],
			
			
			formData: {
				search_type: 'sku_name',
				search_text:'',
				is_reply: 0,
				explain_type:'',
				start_time: '',
				end_time: '',
			},
			orderList: [],
			order: {
				evaluate_id: '',
					is_first_explain: 0,
			}
		};
	},
	onLoad(option) {
	},
	onShow() {
		if (this.mescroll) this.mescroll.resetUpScroll();
		this.actionCallback = () => {
			this.mescroll.resetUpScroll();
		};
	},
	methods: {
		//查找当选选中的值
		findCurr(val) {
			var data = this.orderCondition.order_status_list,
				status = 0;
			for (var index in data) {
				if (data[index].type == val) {
					status = parseInt(index) + 1;
					break;
				}
			}
			return status;
		},
		//开始时间
		bindTimeStartChange(e) {
			if (e.detail.value >= this.formData.end_time && this.formData.end_time) {
				this.$util.showToast({
					title: '开始时间不能大于结束时间'
				});
				return false;
			}
			this.formData.start_time = e.detail.value;
		},
		//结束时间
		bindTimeEndChange(e) {
			if (e.detail.value <= this.formData.start_time) {
				this.$util.showToast({
					title: '结束时间不能小于开始时间'
				});
				return false;
			}
			this.formData.end_time = e.detail.value;
		},
		//时间段选择
		dateSelect(e) {
			this.formData.start_time = this.getDay(e);
			this.formData.end_time = this.getNowDate();
		},
		getNowDate() {
			var date = new Date();
			var y = date.getFullYear();
			var m = date.getMonth() + 1; //获取当前月份的日期
			if (m < 10) {
				m = '0' + m;
			}
			var d = date.getDate();
			if (d < 10) {
				d = '0' + d;
			}
			return y + '-' + m + '-' + d;
		},
		getDay(p_count) {
			var dd = new Date();
			dd.setDate(dd.getDate() - p_count); //获取p_count天后的日期
			var y = dd.getFullYear();
			var m = dd.getMonth() + 1; //获取当前月份的日期
			if (m < 10) {
				m = '0' + m;
			}
			var d = dd.getDate();
			if (d < 10) {
				d = '0' + d;
			}
			return y + '-' + m + '-' + d;
		},
		//数据提交
		screenData() {
			var data = this.formData;
			this.showScreen = false;
			this.$refs.mescroll.refresh();
		},
		//标签点击事件
		uTag(val, currType) {
			if (currType == 'explain_list') {
				this.formData.explain_type = val;
			} 
			this.$forceUpdate();
		},
		//重置
		resetData() {
			this.order_label = '';
			this.formData.search = '';
			this.formData.start_time = '';
			this.formData.end_time = '';
			this.formData.order_type = '';
			this.formData.is_reply=0
				this.formData.explain_type=''
			this.$forceUpdate();
		},
		tabChange(is_reply) {
			this.formData.is_reply=is_reply
			this.$refs.mescroll.refresh();
		},
		searchOrder() {
			this.mescroll.resetUpScroll();
		},
		getListData(mescroll) {
			var data = {
				page_size: mescroll.size,
				page: mescroll.num
			};
			if (!this.formData.order_label) {
				this.formData.order_label = 'order_no'
			}
			if (!this.formData.order_type) {
				this.formData.order_type = 'all'
			}
			Object.assign(data, this.formData);

			this.mescroll = mescroll;
			this.$api.sendRequest({
				url: '/shopapi/goods/evaluate',
				data: data,
				success: res => {
					let newArr = [];
					let msg = res.message;
					if (res.code == 0 && res.data) {
						newArr = res.data.list;
					} else {
						this.$util.showToast({
							title: msg
						});
					}
					mescroll.endSuccess(newArr.length);
					//设置列表数据
					if (mescroll.num == 1) this.orderList = []; //如果是第一页需手动制空列表
				
					this.orderList = this.orderList.concat(newArr); //追加新数据
					
				    this.orderList.forEach(v => {
						v.imagesArray =  v.images.split(",")
						v.again_imagesArray =  v.again_images.split(",")
				    });
					
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
		imgError(index, goodsIndex) {
			this.$forceUpdate();
		},
		
		// 卖家备注
		replay(evaluate_id,is_first) {
			this.order.evaluate_id=evaluate_id
			this.order.is_first_explain=is_first
		 	this.$refs.orderEvaluate.show(() => {
		 		this.mescroll.resetUpScroll();
		 	})
		},
	
		
		
		
	}
}
